var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : '127.0.0.1',
  user     : 'root',
  password : 'root',
  database : 'homework'
});
 
connection.connect(function(err) {
  if (err) {
    console.error('error connecting: ' + err.stack);
    return;
  }
 
  console.log('connected as id ' + connection.threadId);
});

connection.query(`INSERT into user(name,old,sex,create_time,update_time) value('张三','25','男','2023-02-21 16:45:08','2023-02-21 16:45:12');`,"测试",(error, results) =>{
    if (error) throw error;
    console.log(results);
});

connection.query(`delete from user where name= '张三'`,(error, results) =>{
    if (error) throw error;
    console.log(results);
});


connection.query('SELECT * from user', function (error, results, fields) {
    if (error) throw error;
    console.log("查询结果是");
    console.log(results);
});



connection.query(`update user set update_time = "2023-02-21 17:06:15" where old = 25`,(error, results) =>{
    if (error) throw error;
    console.log(results);
});


connection.end();
